﻿using MangoMes.Commont.DapperHelps;
using MangoMes.Commont.Domain.Jocker;
using MangoMes.Commont.DTOs;
using MangoMes.Commont.Infrastructures.Interfaces;
using MediatR;

namespace MangoMes.Write.API.Applications.step
{
    public class StepCreatHandler:IRequestHandler<StepCreatCommond, ResultsDTO>
    {

        private readonly IBateRepository<ProcessStep> ProcessStep;

        public StepCreatHandler(IBateRepository<ProcessStep> processStep)
        {
            ProcessStep = processStep;
        }

        public async Task<ResultsDTO> Handle(StepCreatCommond request, CancellationToken cancellationToken)
        {
            var list = new ResultsDTO() {Code=0 };


            var str = "insert ProcessStep values(@Processtepid,@Orderid,@MaterialURl,@AuxiliaryEquipment,@MaterialF,@StepDescription,@Processkid,@MEss)";
            var NEWSTEP = new ProcessStep()
            {
                StepDescription = request.StepDescription,
                AuxiliaryEquipment = request.AuxiliaryEquipment,
                MaterialF = request.MaterialF,
                MaterialURl = request.MaterialURl,
                Orderid = request.Orderid,
                Processtepid = 0,
                Processkid=request.Processkid,
                MEss=request.MEss,


            };
            DapperHelper dapperHelper = new DapperHelper();
            var getdata = await ProcessStep.Add(str, NEWSTEP, dapperHelper.MangoMesWrite);
            return list;


        }
    }
}
